package person.zjh.kaoyansharehub.controller;

import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import person.zjh.kaoyansharehub.utils.ImageCodeUtil;

import java.io.IOException;

/**
 * @description: TODO
 * @author 郑佳豪
 * @date 2025/2/12 23:33
 * @version 1.0
 */
@Controller
@RequestMapping("/code")
public class CodeController {

    @RequestMapping("/getCode")
    public void getCode(HttpServletResponse response, HttpSession session) throws IOException {
        ImageCodeUtil imageCodeUtil = new ImageCodeUtil();
        String code = imageCodeUtil.getCode();
        session.setAttribute("verCode",code);
        imageCodeUtil.write(response.getOutputStream());
    }


}
